﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NLog;

public partial class logout : System.Web.UI.Page
{
    #region Variables 
    private static Logger _logger = LogManager.GetCurrentClassLogger(); 
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Session.Remove("sessionUser");
            RemoveCookie("LiveKoraCookie");
            Session.Abandon();
            Response.Redirect("/", false);
        }
    }

    private void RemoveCookie(string cookieName)
    {
        try
        {
            System.Web.HttpCookie cookie = new System.Web.HttpCookie(cookieName);
            cookie.Expires = DateTime.Now.AddDays(-1);
            cookie.Name = cookieName;
            cookie.Value = null;
            HttpContext.Current.Response.Cookies.Add(cookie);
        }
        catch (Exception ex)
        {
            _logger.Error("logout:::RemoveCookie:::" + ex.Message);
        }
    }
}